#include <iostream>
#include <stdio.h>
#include <string.h>
#include <queue>
using namespace std;
int xa, ya, xb, yb;
char a[3], b[3];
struct node
{
    int x;
    int y;
    int t;
} first, nextb;
int map[10][10];
int dir[8][2] = {-2, 1, -2, -1, -1, 2, -1, -2, 1, 2, 1, -2, 2, -1, 2, 1};

void bfs()
{
    int i;
    queue<node> q;
    first.x = xa;
    first.y = ya;
    first.t = 0;
    q.push(first);
    map[first.x][first.y] = 1;
    while (!q.empty())
    {
        first = q.front();
        //printf("---%d---%d\n",first.x,first.y);
        q.pop();
        if (first.x == xb && first.y == yb)
        {
            printf("To get from %s to %s takes %d knight moves.\n", a, b, first.t);
            return;
        }
        for (i = 0; i < 8; i++)
        {
            nextb.x = first.x + dir[i][0];
            nextb.y = first.y + dir[i][1];

            if (nextb.x < 0 || nextb.x >= 8 || nextb.y < 0 || nextb.y >= 8)
            {
                //printf("1\n");
                continue;
            }
            if (map[nextb.x][nextb.y] == 1)
            {
                //printf("2\n");
                continue;
            }

            map[nextb.x][nextb.y] = 1;
            nextb.t = first.t + 1;
            q.push(nextb);
        }
    }
}

int main()
{

    while (~scanf("%s%s", &a, &b))
    {
        xa = a[0] - 'a';
        ya = a[1] - '1';
        xb = b[0] - 'a';
        yb = b[1] - '1';

        memset(map, 0, sizeof(map));
        for (int i = 0; i < 10; i++)
        {
            for (int j = 0; j < 10; j++)
            {
                map[i][j] = 0;
            }
        }
        //printf("a=%s\n",a);
        //printf("b=%s\n",b);
        bfs();
    }
    return 0;
}

// https://developer.aliyun.com/article/272952